# -*- coding: utf-8 -*-

import httplib2
import simplejson

class ServerHttp:
    def __init__(self, uri, username, password):
        self.uri = uri
        self.username = username
        self.password =  password

    def send(self,strjson):
        h = httplib2.Http(disable_ssl_certificate_validation=True)
        h.add_credentials(self.username,self.password)
        headers = {}
        params = 'data=%s' % httplib2.urllib.quote_plus(strjson)
        resp, content = h.request(self.uri,'POST',headers=headers,body=params)
        return content

class Sender:
    def __init__(self, username, password):
        self.username = username
        self.password = password
        self.server=ServerHttp('https://sms.vgnet.com.ar/api/2.0/mkt',username, password)

    def send(self,to,subject,text,html):
        hsh = { 'to': to,
                'subject': subject,
                'text': text,
                'html': html,
            }
        j = simplejson.dumps(hsh)
        return self.server.send(j)
